package com.colin.aiyi.adapter;

import android.net.Uri;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.colin.aiyi.R;
import com.colin.aiyi.app.Constant;
import com.colin.aiyi.entity.Status;
import com.colin.aiyi.entity.YiJuAndYiShuoEntity;
import com.colin.aiyi.utils.MusicUtil;
import com.colin.aiyi.utils.TimeUtil;
import com.colin.aiyi.view.ShareBottomDialog;

import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * Created by hl on 2017/5/8.
 * 语录 adapter
 *
 */

public class SentenceAdapter extends BaseQuickAdapter<YiJuAndYiShuoEntity, BaseViewHolder> {

    public SentenceAdapter(@Nullable List<YiJuAndYiShuoEntity> data) {
        super(R.layout.item_yulu, data);
    }


    @Override
    protected void convert(BaseViewHolder helper, YiJuAndYiShuoEntity item) {
        String y;
        int month=TimeUtil.getInt(item.getUpdatedDate(),Calendar.MONTH);
        if (month<10){
            y="0"+month;
        }else {
            y=month+"";
        }
        String m= TimeUtil.getInt(item.getUpdatedDate(),Calendar.DAY_OF_MONTH)+"";
        helper.setText(R.id.text_mooth,y);
        helper.setText(R.id.text_date,m);
        helper.addOnClickListener(R.id.text_like).addOnClickListener(R.id.text_share);
        helper.setText(R.id.text_decs, item.getContent().replace("\\n","").replace("\\r",""));
        helper.setText(R.id.text_like,item.getLikeCount()+"");
        helper.setText(R.id.text_pulish,item.getPublishUser());
        helper.setText(R.id.text_share,"");
        ((TextView)helper.getView(R.id.text_share)).getCompoundDrawables()[0].setLevel(1);
        ImageView imageView = helper.getView(R.id.img);
        Glide.with(imageView.getContext()).load(Constant.BASE_URL+item.getPictureUrl()).error(R.mipmap.pic2).into(imageView);
        ((TextView)helper.getView(R.id.text_like)).getCompoundDrawables()[0].setLevel(0);
        if (item.getLikeCountActive()==1){
            ((TextView)helper.getView(R.id.text_like)).getCompoundDrawables()[0].setLevel(1);
        }
    }
}
